import React, {Component} from 'react';
import {require} from "../../../netWork";
import './RoutingHouse.scss'
import {baseUrl} from "../../../utiles/baseUrl";

class RoutingHouse extends Component {
    state = {
        //租房小组
        groups: []
    };
    //获取数据
    getGroups = () => {
        require({
            url: '/home/groups',
            data: 'AREA|88cff55c-aaa4-e2e0'
        }).then(res => {
            // console.log(res);
            res.body.map(res => {
                // console.log(res);
                res.imgSrc = baseUrl + res.imgSrc;
                return 0
            });
            this.setState({groups: res.body})
            // console.log(this.state.groups);
        }).catch(onerror => {
            console.log(onerror);
        })
    };
    groupsView = () => {
        const {groups} = this.state
      return   groups.map(item => {
            return <div key={item.id} className='item'>
                <div className='title'>
                    <div>{item.title}</div>
                    <div>{item.desc}</div>
                </div>
                <img src={item.imgSrc} alt=""/>
            </div>
        })

    }

    componentDidMount() {
        this.getGroups()
    }

    render() {

        return (
            <div className='routing_house'>
                <div className='more'>
                    <span>租房小组</span>
                    <span className='last'>更多</span>
                </div>
                <div className='group_item'>
                    {
                        this.groupsView()
                    }
                </div>

            </div>
        );
    }
}

export default RoutingHouse;
